<!doctype html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>

<script>
    var name = 'windowName'

    const obj = {
        name: 'objName',
        sayName: function (a, b) {
            console.log(this.name, a, b);
        }
    }

    const foo = {
        name: 'fooName'
    }

    const sayName = obj.sayName.bind(globalThis, 1, 2)
    const sayName2 = obj.sayName.bind(foo, 1, 2)
    const sayName3 = obj.sayName.bind(null, 1, 2)
    const sayName4 = obj.sayName.bind(undefined, 1, 2)
    const sayName5 = obj.sayName.bind(false, 1, 2)
    sayName()   // windowName 1 2
    sayName2()  // fooName 1 2
    sayName3()  // windowName 1 2
    sayName4()  // windowName 1 2
    sayName5()  // undefined 1 2
</script>

</body>
</html>
